package com.tcm.controller.backend;

import com.tcm.common.enums.ResponseEnum;
import com.tcm.entity.dto.CodeUpdateDto;
import com.tcm.entity.vo.ClazzSelectResult;
import com.tcm.entity.vo.GradeSelectResult;
import com.tcm.entity.vo.OrgSelectResult;
import com.tcm.entity.resp.R;
import com.tcm.service.OptionsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 下拉框选项控制器
 * @author Guqier
 * @version 1.0
 * @date 2023/7/8 17:21
 */
@Slf4j
@RestController
@RequestMapping("/pc/options")
public class OptionsController {

    @Autowired
    private OptionsService optionsService;

    /**
     * 获取学院选项列表
     * @return 响应选项列表
     */
    @RequestMapping(value = "/college", method = RequestMethod.GET)
    public R getCollegeList(){
        List<OrgSelectResult> collegeList = optionsService.getCollegeList();
        return R.success(collegeList);
    }

    /**
     * 获取指定学院下的专业选项列表
     * @param id 学院ID
     * @return 响应选项列表
     */
    @RequestMapping(value = "/major", method = RequestMethod.GET)
    public R getMajorList(Long id){
        if (id == null) {
            return R.fail(ResponseEnum.PARAM_IS_BLANK);
        }
        List<OrgSelectResult> majorList = optionsService.getMajorList(id);
        return R.success(majorList);
    }

    /**
     * 获取年级选项列表
     * @return 年级选项列表响应对象
     */
    @RequestMapping(value = "/grade", method = RequestMethod.GET)
    public R getGradeList(){
        List<GradeSelectResult> gradeList = optionsService.getGradeList();
        return R.success(gradeList);
    }

    /**
     * 获取班级选项列表
     * @param majorId 专业ID
     * @param gradeId 年级ID
     * @return 班级列表
     */
    @RequestMapping(value = "/clazz", method = RequestMethod.GET)
    public R getClazzList(Long majorId, Long gradeId){
        List<ClazzSelectResult> clazzSelectList = optionsService.getClazzSelectList(majorId, gradeId);
        return R.success(clazzSelectList);
    }

    /**
     * 获取图片类型
     * @return 图片类型列表
     */
    @RequestMapping(value = "/imageType", method = RequestMethod.GET)
    public R getImageTypeList(){
        List<CodeUpdateDto> imageTypeList = optionsService.getImageTypeList();
        return R.success(imageTypeList);
    }

    /**
     * 获取题目难度列表
     * @return 题目难度列表
     */
    @RequestMapping(value = "/diff", method = RequestMethod.GET)
    public R getDifficultyList(){
        List<CodeUpdateDto> itemDifficultyList = optionsService.getItemDifficultyList();
        return R.success(itemDifficultyList);
    }

    /**
     * 获取病症类别列表
     * @return 病症类别列表
     */
    @RequestMapping(value = "/category", method = RequestMethod.GET)
    public R getCategoryList(){
        List<CodeUpdateDto> categoryList = optionsService.getCategoryList();
        return R.success(categoryList);
    }

    /**
     * 获取社会化项目类型列表
     * @return 社会化项目类型列表
     */
    @RequestMapping(value = "/projectType", method = RequestMethod.GET)
    public R getSocialProjectTypeList(){
        List<CodeUpdateDto> socialProjectType = optionsService.getSocialProjectType();
        return R.success(socialProjectType);
    }

    /**
     * 获取考试难度
     * @return 考试难度列表
     */
    @RequestMapping(value = "/testDiff", method = RequestMethod.GET)
    public R getTestDiffList(){
        List<CodeUpdateDto> socialProjectType = optionsService.getTestDiffList();
        return R.success(socialProjectType);
    }

}
